package com.emm.yixun.mobile.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.emm.yixun.mobile.R;
import com.emm.yixun.mobile.model.GetMarketingControlList.UnitList;
import com.eroad.product.tools.MyGridView;
import com.eroad.product.tools.MyListView;

public class MarKetingAdapter extends BaseAdapter {

	Activity context;

	ArrayList<UnitList> list;

	public MarKetingAdapter(Activity context, ArrayList<UnitList> unitList) {
		this.context = context;
		this.list = unitList;
	}

	@Override
	public int getCount() {
		return list == null ? 0 : list.size();
	}

	@Override
	public Object getItem(int position) {
		return list == null ? null : list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHoudlerMarKeting v = null;
		if (convertView == null) {
			convertView = LayoutInflater.from(context).inflate(R.layout.marketing_item1, null);
			v = new ViewHoudlerMarKeting();
			v.name_marketing = (TextView) convertView.findViewById(R.id.name_marketing);
			v.none_scrollview_list = (MyListView) convertView.findViewById(R.id.none_scrollview_list);
			v.grid = (MyGridView) convertView.findViewById(R.id.grid);
			convertView.setTag(v);
		} else {
			v = (ViewHoudlerMarKeting) convertView.getTag();
		}
		v.name_marketing.setText(list.get(position).getUnitName());

		Hzor_adapter adapter = new Hzor_adapter(context, list.get(position).getFloorList());

		v.none_scrollview_list.setAdapter(adapter);

		return convertView;
	}

	public static class ViewHoudlerMarKeting {
		TextView name_marketing;
		MyListView none_scrollview_list;
		MyGridView grid;
	}

}
